#!/usr/bin/env python3
# -*- coding: utf-8 -*-

# 面向对象编程 OOP

# 风格1
def cat_speek(n=2):
    print('喵喵喵' * n)

def dog_speek(n=2):
    print('汪汪汪'*n)

def bird_speek(n=2):
    print('渣渣渣'*n)

def rat_speek(n=2):
    print('吱吱吱'*n)

def human_speek(n=2):
    print('blahblahblah'*n)

# 风格2
def speek(animal, n=2):
    if animal == 'cat':
        print('喵喵喵'*n)
    elif animal == 'dog':
        print('汪汪汪'*n)
    else:
        ...


class Animal:
    # {'name':'', 'word': ''}
    def __init__(self, name, word='喵'):
        # 魔法方法; 方法就是一种函数
        self.name = name
        self.word = word

    def speek(self, n=2):
        print('我是', self.name)
        print(self.word * n)

class Cat(Animal):
    def __init__(self, name):
        # 魔法方法
        super(Cat, self).__init__(name, '喵')

class Dog(Animal):
    def __init__(self, name):
        # 魔法方法
        super(Dog, self).__init__(name, '汪')


dog=Dog('忠犬八公')  
